package NonGreedySolution;
use strict;
use SurvivalProbability;


=head1 NAME

SetSolution - Stores subsets of species corresponding to greedy solutions

=head1 DESCRIPTION

For more complicated instances of the NAP and the g-NAP (which allows non-
linear cost-benefit relationships) the solutions do not satisfy a substructure
property. eg. a Solution for 3 species is not necessarily part of a solution 
for 5 species, the latter may contain a completely different set of species.

This data structure can be used to store all solutions up to a given number of 
species/units of expenditure. 

=begin comment

 Type    : Constructor
 Title   : new
 Usage   : my $sol = NonGreedySolution->new
 Function: Initializes a NonGreedySolution object.
 Alias   :
 Returns : A NonGreedySolution object.
 Args    : 

=end comment

=cut

sub new {
	my $class = shift;
    my $self;
    
    #The list of species
    $self->{species}=[];
    #The solution will contain a list for each species, the ith element of which
    #corresponds to the expenditure on that species if i units are spent in total
    $self->{solution}=[];
    #The EPD obtained by different conservation expenditures
    $self->{EPD}=[];
    #The value of one budgetary unit -- used for conversions
    $self->{budget_base_unit}=1;

    bless $self, $class;
    return $self;	
}

sub set_with_rats {
	my $self = shift;
	my $tree = shift;
	my $cb = shift;
	
	my $solution = rats($tree,$cb);
	$self->set_with_rats_string($solution);
}

sub set_with_rats_string {
	my $self = shift;
	my $sol = shift;
	
    #Separate string into lines
    my @lines = ($sol =~ /.+/g);
    
    #Remove header lines -> we are assuming that species are in alphabetic order!
	#An assumption to be rectified in future...    
    while (substr($lines[0],0,1) eq '0') { shift @lines; }  
	
	#Get expenditure for each budget
	for (my $budget = 0; $budget <= @lines; $budget++) {
		$line = $lines[$budget];
		
	}
	
}

sub get_n_species {
	
}

sub get_cost {
	
}